package com.bytefy.server.sandbox;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

public class Response {
	private static final String CRLF = "\r\n";
	private HttpServletResponse response;
	
	public Response(HttpServletResponse response) {
		this.response = response;
	}
	
	public void print(Object o) {
		try {
			response.getWriter().print(o);
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
	
	public void println(Object o) {
		print(o);
		print(CRLF);
	}
	
	public void setHeader(String name, String value) {
		response.setHeader(name, value);
	}
	
	public void redirect(String url) {
		setHeader("Location", url);
	}
	
	public void setStatus(int code) {
		response.setStatus(code);
	}
}
